import java.util.Arrays;
import java.util.List;

public class FullReductionPromotionCalculator implements PromotionCalculator {
    private static final SalesPromotion salesPromotion = new SalesPromotion("BUY_30_SAVE_6_YUAN", "Deduct 6 yuan when the order reaches 30 yuan", Arrays.asList());

    @Override
    public PromotionResult calculate(List<OrderItem> orderItems) {
        Double totalAmount = orderItems.stream().map(OrderItem::getAmount).reduce(Double::sum).get();
        double savedAmount = totalAmount > 30 ? 6 : 0;

        return new PromotionResult(savedAmount, salesPromotion);
    }
}
